<?php
require_once('../../config.php');
require_once('security.php');

session_start();
	
//print_r($_POST);
//print_r($_SESSION);
//if (isset($_SESSION['zarray'])){ $zarray=$_SESSION['zarray'];}

//http://localhost/lecmx/cms/admin/ttt.php?field=0&delim=%20&file=ttt.php
if (isset($_GET["file"])){ $_SESSION['file']=htmlspecialchars($_GET["file"]);}
if (isset($_GET["field"])){ $_SESSION['field']=htmlspecialchars($_GET["field"]);}
if (isset($_GET["delim"])){ 
	if ($_GET['delim'] == ''){
		$_SESSION['delim']=' ';
	}else if ($_GET['delim'] == '%20'){
		$_SESSION['delim']=' ';
	}else{
		$_SESSION['delim']=htmlspecialchars($_GET['delim']);
	}
}
unset($_GET['file']);
unset($_GET['field']);
unset($_GET['delim']);

echo $_SESSION['field'] .",," .$_SESSION['delim'] .",," .$_SESSION['file'] .",," .$_GET['file'] ."<br />";
include_once('functions.php');
$done=0;

if (isset($_POST['doorder']) && $_POST['doorder'] != "Make Selection" ){
	$point=$_POST['doorder'];
	if (isset($_POST['up'])){
		$_SESSION['zarray']=moveup($_SESSION['zarray'],$_POST['doorder'],$_SESSION['field'],$_SESSION['delim'],$_SESSION['file']);
		$zarray=$_SESSION['zarray'];
		$done++;
	}else if (isset($_POST['down'])){
		$_SESSION['zarray']=movedown($_SESSION['zarray'],$_POST['doorder'],$_SESSION['field'],$_SESSION['delim'],$_SESSION['file']);
		$zarray=$_SESSION['zarray'];
		$done++;
	}
}else if (isset($_POST['save'])){
	unset($_SESSION['file']);
	unset($_SESSION['field']);
	unset($_SESSION['delim']);
	unset($_GET['file']);
	unset($_GET['field']);
	unset($_GET['delim']);
	headers("http://localhost/lecmx/cms/admin/index.php");
	//$fh=fopen();
//	$done++;
	$point=-1;
}else{
	$zarray=file("ttt");
	$point=-1;
}

//echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
?>
<!--
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Delete a page</title>
<meta name="robots" content="noindex,nofollow" />
<link rel="stylesheet" href="theme/standardtheme/adminstyle.css" type="text/css" media="screen" />
</head>
<body>
-->
<?php

if ($done==0 && isset($zarray)){$_SESSION['zarray']=display($zarray,0," ","ttt.php",-1);}
$_SESSION['point']=$point;
//foreach($zarray as $v){
//	echo $v;
//}
//echo "<br />========<br />";
//print_r($_POST);

//$zarray=moveup($zarray,3);

//foreach($zarray as $v){
//	echo $v;
//}

?>
